package dual_type;

import java.util.HashMap;

public class DualType {
	private String[] dictionary = {};
	
	private HashMap<String, String> pairsLeft = new HashMap<String, String>();
	private HashMap<String, String> pairsRight = new HashMap<String, String>();
	
	private String[] left = {"q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b"};
	private String[] right = {"p", "w", "i", "u", "y", ";", "l", "k", "j", "h", "/", ".", ",", "m", "n"};
	
	/**
	 * Populates a target map with provided keys and values
	 * 
	 * @precondition keyArray and valueArray are the same length
	 * @param keyArray
	 * @param valueArray
	 * @param targetMap
	 */
	public void populate(Object[] keyArray, Object[] valueArray, HashMap<Object, Object> targetMap) {
		for(int i = 0; i < keyArray.length; i++) {
			targetMap.put(keyArray[0], valueArray[0]);
		}
	}
	
	public boolean isCharMatching(String fromString, String fromDictionary, int hand) {
		if(fromString.equals(fromDictionary))
			return true;
		if(hand == 0) { //left hand
			if(!pairsLeft.containsKey(fromString))
				return false;
			return (fromDictionary.equals(pairsLeft.get(fromString)));
		} else if (hand == 1) { //right hand
			if(!pairsRight.containsKey(fromString))
				return false;
			return (fromDictionary.equals(pairsRight.get(fromString)));
		}
		return false;
	}
}
